package bookTest;

public class Cylinder extends Circle{
    private double height;
    public Cylinder(){}
    public Cylinder(double height,double r){
        super(r);
        this.height = height;
    }

    public void setHeight(double height) {
        this.height = height;
    }

    @Override
    public void setR(double r) {
        super.setR(r);
    }

    @Override
    public double getR() {
        return super.getR();
    }

    public double getHeight() {
        return height;
    }
    public double volume(){
        //底面积*高
        return super.area()*height;
    }

    @Override
    public double area() {
        //周长*高+底面积*2
        return super.circumference()*height+super.area()*2;
    }
    @Override
    public String toString(){
        //System.out.println("表面积："+this.area()+" 体积："+this.volume());
        return "表面积："+this.area()+" 体积："+this.volume();
    }
}
